<%
Session.codepage = 65001
Dim conn,Rs,gconnstr
'MySQL 5.1 Connection
gconnstr = "DRIVER={MySQL ODBC 5.1 Driver}; UID=root;PWD=01200;SERVER=localhost;DATABASE=riverrush;"
on error resume next
Set conn=Server.CreateObject("Adodb.Connection")
Conn.Open gconnstr
Set Rs = Server.CreateObject("Adodb.Recordset")
if err<>0 then
response.write err.description
end if
	if request("submit")<>"" then
		name = replace(request("name"),"'","")
		location = replace(request("location"),"'","")
		score = replace(request("score"),"'","")
		
		if name<>"" and location<>"" and score<>"" then
			if len(name)<20 and len(location)<5 and len(score)<5 then
				conn.execute "INSERT INTO highscores (USERNAME,HIGHSCORE,LOCATION,SUBMITDATE) VALUES ('"&name&"','"&score&"','"&location&"',NOW())"
			end if
		end if
	end if
	
	if request("list")<>"" then

		rs.open "SELECT USERNAME as name,LOCATION as location,HIGHSCORE as score,SUBMITDATE as sdate from highscores order by score desc limit 0,10",conn
		if rs.eof then
			response.write "null"
		else
			do until rs.eof
			response.write replace(rs("name"),",","\,")&","&replace(rs("location"),",","\,")&","&replace(rs("score"),",","\,")&","&replace(rs("sdate"),",","\,")
			rs.movenext
if not rs.eof then
	response.write "|"
end if
			loop
		end if
	end if

%>